import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

//以use开头的函数为HOOKS，react中常用
//defineStore用来定义全局状态的方法
export const useCounterStore = defineStore('counter', () => {
  //状态名称
  const count = ref(0)
  //使用计算属性
  const doubleCount = computed(() => count.value * 2)
  //修改函数
  function increment() {
    count.value++
  }

  return { count, doubleCount, increment }
})
